using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

namespace DataStructure
{
    public class Array1Stack<T> : IStack<T>
    {
        private Array1<T> arr;
        public Array1Stack(int capacity)
        {
            arr = new Array1<T>(capacity);
        }
        public Array1Stack()
        {
            arr = new Array1<T>();
        }
        
        public int Count => arr.Count;

        public bool IsEmpty => arr.IsEmpty;
        //入栈
        public void Push(T data)
        {
            arr.AddLast(data);
        }
        
        //出栈
        public T Pop()
        {
            return arr.RemoveLast();
        }
        
        //查看栈顶元素
        public T Peek()
        {
            return arr.GetLast();
        }

        public override string ToString()
        {
            return "Stack" + arr.ToString() + "Top";
        }
    }
}